<%@ page language="java"
	import="java.util.*,news.dao.*,news.pojo.*,news.util.*"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>登陆处理页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<%
		String uname = request.getParameter("uname");
		String upwd = request.getParameter("upwd");
		String k = request.getParameter("keep");
		System.out.print(k);
		UserDao userdao = new UserDao();
		News_users userlist = userdao.login(uname, upwd);		
		if (userlist != null) {

			if (k!=null&&k.equals("1")) {
				Cookie c1 = new Cookie("USER_NAME", uname);
				Cookie c2 = new Cookie("USER_PASS", upwd);

				c1.setMaxAge(86400 * 7);
				c1.setPath("/");
				c2.setMaxAge(86400 * 7);
				c2.setPath("/");
				response.addCookie(c1);
				response.addCookie(c2);
				
			}							
				session.setAttribute("uname", uname);
				session.setAttribute("upwd", upwd);
				response.sendRedirect("admin.jsp");
		} else {
		out.print("<script>location='index.jsp';alert('账号密码错误！');</script>");
			//response.sendRedirect("index.jsp");
		}
	%>
</body>
</html>
